-- @owner: kyleze
-- @date: 2024-10-20
-- @testpoint: int(n)作为对象名测试,部分合理报错

--prestep1:切换B库;expect:执行成功
@conn PrimaryDbBmode;
show sql_compatibility;

--step1:作为列名 expect:成功
drop table if exists int_test cascade;
create table int_test(int int);
insert into int_test values('0');

--step2:作为索引名 expect:成功
create index int on int_test(int);
drop table if exists int_test cascade;

--step3:作为表名 expect:成功
drop table if exists int cascade;
create table int(int int);
insert into int values('1');
select * from int;
drop table if exists int cascade;

--step4:作为数据库名 expect:成功
drop database if exists int;
create database int;drop database int;

--step5:作为外部数据源名 expect:成功
drop data source if exists int;
create data source int;
drop data source int;

--step6:作为自定义函数名 expect:报错
create or replace function int(c1 int(666))
returns int(666)
as  $$
begin
    return c1;
end;
$$
language plpgsql;
/

--step7:作为存储过程名 expect:报错
create or replace procedure int(p1 in int(666)) as
begin
    insert into t_int_0023 values ('00001');
    raise info '测试int作为存储过程名';
end;
/

--step8:作为角色名 expect:成功
drop role if exists int;
create role int with password 'gauss@123' valid until '2001-12-12';
drop role int;

--step9:作为用户组名 expect:成功
drop group if exists int;
create group int with password 'gauss@123';
drop group int;

--step10:作为模式名 expect:成功
drop schema if exists int;
create schema int;
drop schema int;

--step11:作为序列名 expect:成功
create sequence public.int start 100 cache 50;
drop sequence public.int;

--step12:作为用户名 expect:成功
drop user if exists int;
create user int password 'Bigdata@123';
drop user int;

--step13:前置条件 expect:成功
drop table if exists int_test cascade;
create table int_test(cid int,fid int);

--step14:作为游标名号-成功 expect:成功
start transaction;
cursor int for select * from int_test order by 1;
close int;
end;

--step15:清理环境 expect:成功
drop table if exists int_test cascade;

